package br.com.busgps.resource;

import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import br.com.busgps.dao.impl.BusDAOImpl;
import br.com.busgps.dao.impl.LocationDAOImpl;
import br.com.busgps.util.Constants;

import com.google.gson.Gson;

/**
 * 
 * Classe responsavel por receber requisicoes e devolver informacoes.
 * 
 * @author Rodrigo
 * 
 */
@Path(Constants.BUS_PATH)
@Produces(MediaType.APPLICATION_JSON)
public class BusResource
{

    private final Logger logger = LoggerFactory.getLogger(BusResource.class);

    @GET
    @Path(Constants.SLASH + Constants.BY_NUMBER + Constants.SLASH + "{" + Constants.NUMBER + "}")
    public String getByNumber(@PathParam(Constants.NUMBER) String number)
    {
        return new Gson().toJson(new BusDAOImpl().getByNumber(number));
    }

    @GET
    @Path(Constants.SLASH + Constants.BY_ORDER + Constants.SLASH + "{" + Constants.ORDER + "}")
    public String getById(@PathParam(Constants.ORDER) String ordem)
    {
        return new Gson().toJson(new BusDAOImpl().getByOrdem(ordem));
    }

    @GET
    @Path(Constants.SLASH + Constants.BY_BUS_STOP + Constants.SLASH + "{" + Constants.BUS_STOP_ID + "}")
    public String getByBusStop(@PathParam(Constants.BUS_STOP_ID) String id)
    {
        return null;
    }

    @GET
    @Path(Constants.SLASH + Constants.ALL_BUSES)
    public String getAllBuses()
    {
        return new Gson().toJson(new LocationDAOImpl().getAll());
    }
}
